import json
import unittest

from parameterized import parameterized

import config

from api.getExamExplain import GetExamExplain
from lib.mobile_no_login import MBlogin

import requests

# 获取诊断id
class ExamId:
    examId = 1945
    @classmethod
    def setexamId(cls,examid):
        cls.examId = examid
        return cls.examId

def BuildData():
    mobile_no = []
    data_file = config.BASE_DIR + "/data/mobile_no.json"
    with open(data_file, encoding="utf-8") as f:
        receivedata = json.load(f)["mobile_no"]
        for i in receivedata:
            mobile_no.append((i,))
    print(mobile_no)
    return mobile_no

class TestExplain(unittest.TestCase):
    def setUp(self):
        self.session = requests.session()
        self.examid = ExamId().examId

    def tearDown(self):
        self.session.close()

    @parameterized.expand(BuildData())
    def test01_getExamExplain(self,mobile_no):
        token = MBlogin().mbLogin(mobile_no)
        params = {
            "param": {
                "reqVO": {
                    "examId": self.examid,
                    "purposeId": None,
                    "purposeType": 1,
                    "examType": None,
                    "groupPaperId": None,
                    "examMemberId": None
                }
            },
            "service_name": "learnprod.ExamMemberFacade.getExamExplain",
            "strategy": "dubbo",
            "client_id": "6",
            "timestamp": 1710468093669,
            "token": token
        }
        responses = GetExamExplain().getExamExplain(self.session, params)
        config.prints(responses)
        print(responses.json())
        self.assertEqual('1000001',responses.json()['code'])

